package Server;

import java.sql.*;

public class ZbiorKsiazek
    {
    private Connection _con;

    private ZbiorKsiazek() throws ClassNotFoundException, SQLException
        {
        Class.forName( "com.microsoft.sqlserver.jdbc.SQLServerDriver" );

        String connectionUrl = "jdbc:sqlserver://localhost:1433;"
                + "databaseName=Biblioteka;user=ztsr;password=corba;";
        _con = DriverManager.getConnection( connectionUrl );
        
        String SQL = "SELECT Autor FROM Ksiazki";
        Statement stmt = _con.createStatement();
        ResultSet rs = stmt.executeQuery(SQL);

        while (rs.next())
           System.out.println(rs.getString("Autor"));
           
        }

    private static ZbiorKsiazek _instance;

    public static ZbiorKsiazek GetInstance()
        {
        try
            {
            if( _instance == null )
                _instance = new ZbiorKsiazek();
            return _instance;
            } catch( Exception e )
            {
            e.printStackTrace( System.out );
            return null;
            }
        }

    }
